package com.cloud.test.usercustomerfegionhystrix.fallback;


import com.cloud.test.usercustomerfegionhystrix.pojo.User;
import com.cloud.test.usercustomerfegionhystrix.userFeignClient.UserFeign2;
import com.cloud.test.usercustomerfegionhystrix.userFeignClient.UserFeign2Fallback;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class HystrixCommandFallbackFactory  implements FallbackFactory<UserFeign2> {
   private static final Logger log=LoggerFactory.getLogger(HystrixCommandFallbackFactory.class);

    @Override
    public UserFeign2 create(Throwable throwable) {
        log.info(throwable.getMessage());

        return new UserFeign2Fallback() {
            @Override
            public User getUser(Integer id) {
                return new User();
            }
        };
    }
}
